package cn.tedu.spring.di;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/*
注入对象
 */
@Service
public class UserService {
    @Value("用户业务")
    private String name;
    /*
    @Autowired
    添加位置:1.属性注入属性上
    2.set方法注入。添加在set()方法上
    3.构造方法注入：添加在构造方法上
     */
//    @Autowired    属性注入
    private UserDao userDao;
//@Autowired  set方法注入
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }
@Autowired  //构造方法注入
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "name='" + name + '\'' +
                ", userDao=" + userDao +
                '}';
    }
}
